<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>jquery.cme-tag</title>
    <link rel="stylesheet" href="../dist/css/cmetag-blue.css">
    <script src="../bower_components/jquery/dist/jquery.min.js" type="text/javascript"></script>
    <script src="../dist/js/jquery.cme-tag.js" type="text/javascript"></script>
    <script src="../bower_components/mockjs/dist/mock.js"></script>
    <script src="jquery.cme-tag.js"></script>
</head>

<body>
    选择的tagId：<input type="text" id="tagIds"/>
    选择的tagId：<span id="tagSpan"></span>
	<div id="tagGroup"></div>
    
    <script type="text/javascript">
    	Mock.mock('http://www.cme365.cn/getTagGroupData.jhtml',{
    		code:'success',
    		data:[{
    			key : 1,
    			value : '专业',
    			children : [{
    				key : 2,
    				value : '专业1'
    			},{
    				key : 3,
    				value : '专业2'
    			},{
    				key : 4,
    				value : '专业3'
    			}]
    		},{
    			key : 10,
    			value : '热门',
    			children : [{
    				key : 20,
    				value : '热门1'
    			},{
    				key : 30,
    				value : '热门2'
    			},{
    				key : 40,
    				value : '热门3'
    			}]
    		}]
    	});
    	var cmetag;

    	$(function(){
    		cmetag = $("#tagGroup").cmeTag({
    			ajax : {
    				url : 'http://www.cme365.cn/getTagGroupData.jhtml'
    			},
                el : '#tagSpan',
    			type : 'single',
    			data : '2,40',
    			beforeLoadData : function(data){
    				data = JSON.parse(data);
    				return data.data;
    			},
    			onTagClick : (key,obj)=>{
    				console.log(key);
    			}
    		});
    	});
    </script>
</body>

</html>